//
//  PicCollectionViewCell.m
//  Auditory
//
//  Created by 寒竹子 on 15/4/28.
//  Copyright (c) 2015年 寒竹子. All rights reserved.
//

#import "PicCollectionViewCell.h"
#import "PicModel.h"
#import "UIImageView+WebCache.h"

@implementation PicCollectionViewCell
{
    PicModel * _model;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        _imageView = [[UIImageView alloc] init];
        [self.contentView addSubview:_imageView];
        
        _desLabel = [[UILabel alloc] init];
        _desLabel.textAlignment = NSTextAlignmentCenter;
        _desLabel.font = TextFont(15.0f);
        _desLabel.textColor = [UIColor whiteColor];
        _desLabel.backgroundColor = [UIColor blackColor];
        _desLabel.alpha = .5f;
        [self.contentView addSubview:_desLabel];
    }
    
    return self;
}

- (void)setModel:(PicModel *)model
{
    _model = model;
    
    _imageView.frame = CGRectMake(0, 0, model.imageW, model.imageH);
    [_imageView sd_setImageWithURL:[NSURL URLWithString:model.image_url] placeholderImage:[UIImage imageNamed:@"defaultPic_Bg.jpeg"]];
    
    _desLabel.frame = CGRectMake(0, self.frame.size.height - 25.0f, self.frame.size.width, 25.0f);
    if (model.desc.length > 0) {
        _desLabel.text = model.desc;
    }else {
        _desLabel.text = model.colum;
    }
}

@end
